The new science of animal cognition is forcing countries to overhaul their laws